# -*- coding: utf-8 -*-

import datetime

from mocrud.extend import ObjectOp, ModelOp
import wtforms
from mocrud import ormfields
from mocrud.utils import flash

from ..models import Reader

class CloseReader(ObjectOp):
    verbose_name = u'冻结'
    class OpForm(wtforms.Form):
        name = wtforms.TextField(u'请填写您的姓名', validators=[wtforms.validators.Required()])
        plan_time = ormfields.WPDateField(u'预计归还日期',default=datetime.datetime.now, validators=[wtforms.validators.Required()])
    
    def action(self, form, request):
        print 'ids>>>',request.forms.getall('id')
        flash(u'冻结成功', 'success')
        return self.redirect()
    
class NoticeReader(ModelOp):
    verbose_name = u'到期提醒'
    class OpForm(wtforms.Form):
        name = wtforms.TextField(u'请填写您的姓名', validators=[wtforms.validators.Required()])
        plan_time = ormfields.WPDateField(u'预计归还日期',default=datetime.datetime.now, validators=[wtforms.validators.Required()])
    
    def action(self, form, request):
        print '>>>>>>>>>>',form.data
        flash(u'操作成功', 'success')
        return self.redirect()
    
Reader.Admin.ops = [CloseReader, NoticeReader]